package com.me.study.javaCore.classLoader.classLoadingSeq1.test2;

/**
 * 类加载顺序测试：子类
 *
 * @author ME
 * @date   2019/4/27
 */
public class ChildClass extends TestParentClass {
    private Person person = new Person("[ClassB]      Member variables: person");
    private static Person person1 = new Person("[ClassB]      static Member variables1: person1");

    static {
        System.out.println("[ClassB]      static code block");
    }

    private static Person person2 = new Person("[ClassB]      static Member variables2: person2");

    public ChildClass() {
        System.out.println("[ClassB]      constructor");
    }

    /**
     * TODO 由于同作用域中的加载顺序是从上到下，所以静态代码块申明在静态成员变量前面时，
     *  静态代码块中只能对变量赋值，读取和运算都会编译不通过
     */
    // private static String string = "HH +++ ";
    // private static Person pp;
    // private static int i = 0;

    static {
        // System.out.println(string);
        // System.out.println(string + "static");
        string = "static";
        // pp.eat();
        pp = new Person("[ClassB]      static Member variables3: pp");
        // System.out.println(i);
        // System.out.println(i + 1);
        i = 9;
    }

    private static String string = "HH +++ ";
    private static Person pp;
    private static int i = 0;
    
}
